<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Vue动态组件</title>
    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
</head>

<body>
    <div id="Application">

        <!-- input组件 placeholder="x" 与 title="x" 这两个属性不添加在windows edge中会报警告，最好是有个label给提示一下 -->

        <input type="radio" value="page1" v-model="page" placeholder="x" />页面1
        <input type="radio" value="page2" v-model="page" title="x"/>页面2

        <!-- component是一个特殊的标签，其通过is属性来指定要渲染的组件名称 -->
        <component :is="page"></component>
    </div>
    <script>
        const App = Vue.createApp({
            data() {
                return {
                    // 后面的值不是字符串！
                    page: "page1"
                }
            }
        })

        const page1 = {
            template: `
            <div style="color:red">
                页面组件1-
            </div>`
        }
        const page2 = {
            template: `
            <div style="color:blue">
                页面组件2-
            </div>`
        }

        App.component("page1", page1)
        App.component("page2", page2)
        App.mount("#Application") 
    </script>
</body>

</html>